-- this is executed when the script is run normally -- the 'on run' and 'end run' lines are optional on run say "Script started" say "Script finished" display dialog "Script finished." buttons "OK" default button 1 end run -- this is executed whenever data is dragged onto the script -- data can contain either text or file specs/aliases -- multiple dragged items appear as a list to the script on open x if class of x is string then display dialog ((count words in x) as text) & " words." buttons "OK" default button 1 else if class of x is alias then display dialog "File path: " & x as text buttons "OK" default button 1 else if class of x is list then repeat with i in x tell me to open contents of i end repeat end if end open